package com.qinggeng.project.system.typehandler;

import com.alibaba.fastjson.JSONObject;
import com.qinggeng.project.system.domain.Position;
import com.qinggeng.project.system.domain.Resume;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

@MappedJdbcTypes(JdbcType.VARCHAR)
public class ResumeTypeHandler implements TypeHandler<Resume> {



    @Override
    public void setParameter(PreparedStatement ps, int i, Resume parameter, JdbcType jdbcType) throws SQLException {
        ps.setString(i, JSONObject.toJSONString(parameter));
    }

    @Override
    public Resume getResult(ResultSet rs, String columnName) throws SQLException {
        return JSONObject.parseObject(rs.getString(columnName),Resume.class);
    }

    @Override
    public Resume getResult(ResultSet rs, int columnIndex) throws SQLException {

        return JSONObject.parseObject(rs.getString(columnIndex),Resume.class);

    }

    @Override
    public Resume getResult(CallableStatement cs, int columnIndex) throws SQLException {
        return null;
    }
}
